#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
void Printorder(vector<int>& v1, vector<int>& v2)
{
    vector<int> v3;
    v3.reserve(2 * v1.size());
    int number = v1.size() - 1;
    int flag = 1;
    for (int i = 0; i < 2 * v1.size(); ++i)
    {
        if (flag)
        {
            v3.push_back(v2[number]);
            flag = !flag;
        }
        else
        {
            v3.push_back(v1[number]);
            number--;
            flag = !flag;
        }
    }
    int i = 0;
    int n = v1.size();
    number = 0;
    reverse(v3.begin(), v3.end());
    for(const auto& e : v3)
    {
        if(n == i)
            number = 0;
        if(i < n)
            v1[number] = e;
        else if(i >= n && i < 2 * n)
            v2[number] = e;
        ++i;
        ++number;
    }
    /*for (const auto& e : v3)
    {
        cout << e << " ";
    }
    cout << endl;*/
}
int main()
{
    int num = 0;
    cin >> num;
    while (num--)
    {
        int n = 0;
        cin >> n;
        vector<int> v1;
        vector<int> v2;
        v1.reserve(n);
        v2.reserve(n);
        int k = 0;
        cin >> k;
        int number = 0;
        int i = 0;
        while (cin >> number)
        {
            if (i < n)
                v1.push_back(number);
            else if (i >= n && i < 2 * n)
                v2.push_back(number);
            ++i;
            if (i == 2 * n)
                break;
        }
        while (k--)
        {
            Printorder(v1, v2);
        }
        for(const auto& e : v1)
            cout << e << " ";
        for(const auto& e : v2)
            cout << e << " ";
        cout << endl;
    }
    return 0;
}